package com.caine.androidtask.ls07;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLiteHelper extends SQLiteOpenHelper {
	private String createTableString = null;
    
	public SQLiteHelper(Context context, String name, int version,
			String createTableString) {
		this(context, name, null, version);
		this.createTableString = createTableString;
		// TODO Auto-generated constructor stub
	}
    public SQLiteHelper(Context context ,String name,CursorFactory cursorFactory ,int version){
    	super(context, name, cursorFactory, version);
    	System.out.println("......................");
    }
	
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
	
		if (createTableString != null) {
			db.execSQL(createTableString);
		} else {
			this.createTableString = "CREATE TABLE TB_1(id int,name varchar(10))";
			db.execSQL(createTableString);
		}
		System.out.println("createTableString : " + this.createTableString);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub

	}

	@Override
	public synchronized SQLiteDatabase getReadableDatabase() {
		// TODO Auto-generated method stub
		return super.getReadableDatabase();
	}

	@Override
	public synchronized SQLiteDatabase getWritableDatabase() {
		// TODO Auto-generated method stub
		return super.getWritableDatabase();
	}

}
